package com.lcb.manager.vo;


import com.alibaba.fastjson.JSON;
import com.lcb.manager.entity.Company;

import javax.persistence.Column;
import java.text.SimpleDateFormat;
import java.util.List;

public class CompanyVo {

    private Integer id;

    private Integer num;

    private String date;

    private String title;

    private String content;

    private List<String> pictures;

    private String video;

    private Integer type;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getPictures() {
        return pictures;
    }

    public void setPictures(List<String> pictures) {
        this.pictures = pictures;
    }

    public String getVideo() {
        return video;
    }

    public void setVideo(String video) {
        this.video = video;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public static CompanyVo fromEntity(Company company) {
        if (company == null) return null;
        CompanyVo companyVo = new CompanyVo();
        companyVo.id = company.getId();
        companyVo.num = company.getNum();
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        companyVo.date = sdf1.format(company.getDate());
        companyVo.title = company.getTitle();
        companyVo.content = company.getContent();
        companyVo.pictures = JSON.parseArray(company.getPictures(), String.class);
        companyVo.video = company.getVideo();
        companyVo.type = company.getType();
        return companyVo;
    }
}
